package com.hmy.equipment.service.impl;

import com.hmy.equipment.domain.HmyAutoFeeding;
import com.hmy.equipment.domain.HmyFans;
import com.hmy.equipment.mapper.HmyFansMapper;
import com.hmy.equipment.service.AeviceState;
import com.hmy.equipment.service.HmyFansService;
import com.ruoyi.common.core.web.constant.TableName;
import io.seata.spring.annotation.GlobalTransactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：kdq
 * @description：气体交换机
 * @date ：2024/1/30 19:08
 */
@Service
public class HmyFansServiceImpl implements HmyFansService {

    private static final Logger log = LoggerFactory.getLogger(HmyFansServiceImpl.class);
    @Resource
    private HmyFansMapper hmyFansMapper;

    @Resource
    private AeviceState aeviceState;

    /**
     * * @param null
     *
     * @return
     * @author kdq
     * @date 2024/1/30 19:08
     * @description 气体交换机添加
     */
    @Override
    @GlobalTransactional
    public int addFans(HmyFans hmyFans) {
        //新增设备
        int i = hmyFansMapper.addFans(hmyFans);
        //调用栏舍里的方法，为这个栏舍修改设备的有无
        aeviceState.getPhouseCoudInTable(TableName.FANS, hmyFans.getPhouseCode());
        // 异常
        //int a = 1 / 0;
        return i;
    }


    /**
     * * @param null
     *
     * @return
     * @author kdq
     * @date 2024/1/30 19:08
     * @description 气体交换机修改
     */
    @Override
    public int editFans(HmyFans hmyFans) {
        return hmyFansMapper.editFans(hmyFans);
    }


    /**
     * * @param null
     *
     * @return
     * @author kdq
     * @date 2024/1/30 22:30
     * @description 查询所有气体交换机
     */
    @Override
    public List<HmyFans> selectAll(String fansType,
                                   String fansBrand,
                                   String phouseCode) {
        return hmyFansMapper.selectAll(fansType, fansBrand, phouseCode);
    }


    /**
     * * @param null
     *
     * @return
     * @author kdq
     * @date 2024/1/30 22:32
     * @description 根据id删除单个记录
     */

    @Override
    public int deleteById(String fansType) {
        return hmyFansMapper.deleteById(fansType);
    }

    @Override
    public HmyFans selectByFansId(String fansType) {
        return hmyFansMapper.selectByFansId(fansType);
    }


}
